home *** CD-ROM | disk | FTP | other *** search
/ 1,000+ Great Games / 1_1000 Games.iso / DOSGAMES / BOGGLE.ZIP / SOURCE.ZIP / SOUND.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-03  |  1.6 KB  |  54 lines

  1. /*****************************************************************************
  2. * Program:  SOUND.CPP
  3. * Purpose:  handles the playing of .WAV files
  4. *****************************************************************************/
  5. #include "sound.hpp"
  6.  
  7.  
  8. /*****************************************************************************
  9. * Function: Sound
  10. * Parms:    none
  11. * Purpose:  Constructor - instantiate the WAV audio device 
  12. * Returns:  Nothing
  13. *****************************************************************************/
  14. Sound::Sound()
  15. {
  16.    try
  17.    {
  18.       wavPlayer = new IMMWaveAudio(true);
  19.    }
  20.    catch (IException& exc)
  21.    {
  22.       IString msg = "Could not open the wave audio device.  The wave audio functions are disabled.";
  23.       throw msg;
  24.    }
  25. }
  26.  
  27. /*****************************************************************************
  28. * Function: ~Sound
  29. * Parms:    none
  30. * Purpose:  Destructor - delete the WAV audio device 
  31. * Returns:  Nothing
  32. *****************************************************************************/
  33. Sound::~Sound()
  34. {
  35.    if(wavPlayer) 
  36.       delete wavPlayer;
  37. }
  38.  
  39.  
  40. /*****************************************************************************
  41. * Function: playSound
  42. * Parms:    fileName - filename of the .wav file to play
  43. * Purpose:  calls the IBM class lib functions to load a .WAV file and play it
  44. * Returns:  Nothing
  45. *****************************************************************************/
  46. void Sound::playSound(IString fileName)
  47. {
  48.    wavPlayer->loadOnThread(fileName, true);
  49.    wavPlayer->play();
  50. }   
  51.  
  52.  
  53.  
  54.